package com.hsy.crm.web.utils;

import java.util.Random;

public class RandomUtils {

    private static final Random RANDOM = new Random();

    /**
     * 随机数字
     * @return
     */
    public static String randomInt(int len){
        String code = "";
        for( int i=0 ; i<len ; i++ ){
            code += String.valueOf(RANDOM.nextInt(10));
        }
        return code;
    }

    /**
     * 随机数字+字母
     * @return
     */
    public static String randomCode(int len){
        // a-97  z-122
        // 0-9 10-35
        String code = "";
        for( int i=0 ; i<len ; i++ ){
            int next = RANDOM.nextInt(36);
            if( next < 10 ){
                code += String.valueOf(next);
            }else{
                code += String.valueOf((char)(next+87));
            }
        }
        return code;
    }

    public static int nextInt(int bound){
        return RANDOM.nextInt(bound);
    }

}
